﻿using DoNetDrive.Core.Command;
using DotNetty.Buffers;
using System;
using System.Collections.Generic;
using System.Text;

namespace DoNetDrive.Protocol.Fingerprint.SystemParameter.MasterSlaveMode
{
    /// <summary>
    /// 主从模式命令参数对象
    /// </summary>
    public class WriteMasterSlaveMode_Parameter : ReadMasterSlaveMode_Result, INCommandParameter
    {
        /// <summary>
        /// 主从模式命令参数对象
        /// </summary>
        /// <param name="mode">主从模式</param>
        public WriteMasterSlaveMode_Parameter(E_MasterSlaveMode mode) : base(mode)
        {

        }
        /// <summary>
        /// 获取数据包
        /// </summary>
        /// <param name="databuf"></param>
        /// <returns></returns>
        internal IByteBuffer GetBytes(IByteBuffer databuf)
        {
            databuf.WriteByte((int)Mode);
            return databuf;
        }
        /// <summary>
        /// 检查参数
        /// </summary>
        internal void CheckedParameter()
        {
            if(!Enum.IsDefined(typeof(E_MasterSlaveMode), Mode))
            {
                throw new ArgumentException("Mode Error");
            }
        }
    }
}
